/* Copyright(C): Leaf Johnson 2009,2010

    This file is part of leaf-lib.

    leaf-lib is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    leaf-lib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with leaf-lib.  If not, see <http://www.gnu.org/licenses/>.


 * 
 * 
 */


#ifndef VECTOR_H_INCLUDED
#define VECTOR_H_INCLUDED
#include <leaf/types.h>

#define VECTOR_SIZE_INC 4
typedef uint8_t VectorDataType;

typedef struct{
	size_t capacity;
	VectorDataType   *data;
}Vector;

void vectorInit(Vector *v, size_t bufSize);
void vectorFree(Vector *v);
inline void vectorSet(Vector *v, size_t idx, VectorDataType data);
inline VectorDataType vectorGet(const Vector *v, size_t idx);
int  vectorExtends(Vector *v, size_t size);
int  vectorWrite(Vector *v, size_t idx, const VectorDataType *buf, size_t len);
int  vectorRead(const Vector *src, size_t idx,  VectorDataType *dest, size_t len);
inline int  vectorCopy(Vector *src, size_t srcidx, Vector *dest, size_t destidx, size_t len);
/*很危险的函数，我很想把它弄死*/
void *vectorGetBuffer(Vector *vec, size_t idx);

#endif  /* VECTOR_H_INCLUDED */

